package jdk8;

import java.io.IOException;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;

import org.junit.Test;

public class NewAPIs {

	int[] data = { 4, 12, 1, 3, 5, 7, 9 };

	@Test
	public void parallelSort() {
		// 数组的并行排序
		Arrays.parallelSort(data);
		System.out.println(Arrays.toString(data));
	}

	@Test
	public void testCollectPrallel() {
		// [4, 16, 17, 20, 25, 32, 41]
		Arrays.parallelPrefix(data, Integer::sum);
		System.out.println(Arrays.toString(data));
	}

	@Test
	public void list() throws IOException {
		// 当前目录和子目录的集合
		Files.list(Paths.get(".")).filter(Files::isDirectory).forEach(System.out::println);
	}

	@Test
	public void walk() throws IOException {
		// 遍历当前目录和子目录
		Files.walk(Paths.get("."), FileVisitOption.FOLLOW_LINKS).forEach(System.out::println);
	}
}
